# Example data
set1 := {"member1", "member2"}
array1 := ["member1", "member2"]
object1 := {
    "key1": "value1",
    "key2": "value2"
}

# Checking member or value: successes
output1__member_success if {    # all of the conditions succeed
    "member1" in set1
    "member2" in set1
    "member1" in array1
    "member2" in array1
    "value1" in object1
    "value2" in object1
}

# Checking member or value: failures
output2__member_fail if {   # all of the conditions fail
    "non-member" in set1      # not a member
    "non-member" in array1    # not a member
    1 in array1               # 1 in an index but not a member
    "non-value" in object1    # not a value
    "key1" in object1         # "key1" is a key but not a value
}

# Checking that an index:member mapping is in an array or
# a key:value mapping is in an object
output3__mapping_success if {  # all of the conditions succeed
    array1[0] == "member1"       # check array1 maps index 0 to "member1"
    array1[1] == "member2"       # check array1 maps index 1 to "member2"
    1, "member2" in array1       # alternate form using the in keyword
    object1["key1"] == "value1"  # check object1 maps "key1" to "value1"
    object1["key2"] == "value2"  # check object1 maps "key2" to "value2"
    "key2", "value2" in object1  # alternative form using the in keyword
}

output4__mapping_fail if {     # all of the conditions fail
    array1[1] == "member1"       # index 1 maps to "member2" instead
    array1[2] == "member1"       # index 2 does not exist
    object1["key2"] == "value1"  # "key2" maps to "value2" instead
    object1["key3"] == "value1"  # "key3" does not exist
}

# Checking existence of array index or object key
output5__index_or_key_success if {  # all of the conditions succeed
    some 0, _ in array1  # index 0 maps to some unspecified _
    some 1, _ in array1  # index 1 maps to some unspecified _
    some "key1", _ in object1  # "key1" maps to some unspecified _
    some "key2", _ in object1  # "key2" maps to some unspecified _
}

output6__index_or_key_fail if {  # all of the conditions fail
    some 2, _ in array1        # index 2 does not exist in array1
    some -1, _ in array1       # index -1 does not exist in array1
    some "key3", _ in object1  # key "key3" does not exists in object1
    some 1, _ in object1       # key 1 does not exists in object1
}

# Using [] to check for existence of index or key sometimes fail
array2 := ["member", false]  # example data

output7__index_or_key_bracket if {
    array2[0]    # eval to "member"; condition succeeds
    array2[1]    # eval to false; condition fails
}
